import { generateServices } from "@/utils";
/**
 * name不可重复,否则接口会被后面覆盖
 */
const settings = [
  {
    name: "getExpertCourseList",
    axiosConfig: {
      url: "/train/course/expert/list-course",
      method: "get",
    },
  },
  {
    name: "getFarmerCourseList",
    axiosConfig: {
      url: "/train/course/farmer/list-course",
      method: "get",
    },
  },
  {
    name: "getCourseProblemList",
    axiosConfig: {
      url: "/train/course/list-problem",
      method: "get",
    },
  },
  {
    name: "getOnlineReplyList",
    axiosConfig: {
      url: "/train/course/reply-online",
      method: "get",
    },
  },
  {
    name: "getReplyDetail",
    axiosConfig: {
      url: "/train/course/list-replyDetail",
      method: "get",
    },
  },
  {
    name: "getRecommendExpert",
    axiosConfig: {
      url: "/train-hospital/recommend-expert",
      method: "get",
    },
  },
  {
    name: "getProblemList",
    axiosConfig: {
      url: "/train-hospital/list-problem",
      method: "get",
    },
  },
  {
    name: "getExpertList",
    axiosConfig: {
      url: "/train-hospital/list-expert",
      method: "get",
    },
  },
  {
    name: "getcourseDetailAjax",
    axiosConfig: {
      url: "/train/course/farmer/course-detail",
      method: "get",
    },
  },
  {
    name: "getcourseEvaluateAjax",
    axiosConfig: {
      url: "/train/course/farmer/list-courseEvaluate",
      method: "get",
    },
  },
  {
    name: "postEvaluateCourseAjax",
    axiosConfig: {
      url: "/train/course/farmer/evaluate-course",
      method: "post",
    },
  },
  {
    // 我的服务  列表
    name: "getMyService",
    axiosConfig: {
      url: "/train-hospital/my-service",
      method: "get",
    },
  },
  {
    // 我的服务  评价
    name: "postEvaluate",
    axiosConfig: {
      url: "/train-hospital/evaluate",
      method: "post",
    },
  },
  {
    // 我的服务  查看评价
    name: "seeEvaluate",
    axiosConfig: {
      url: "/train-hospital/get-evaluation-detail",
      method: "get",
    },
  },
  {
    // 农业资讯
    name: "getAgriNews",
    axiosConfig: {
      url: "/train/dynamic/list-dynamic",
      method: "get",
    },
  },
  {
    // 农业资讯   推荐
    name: "getAgriNewsRecom",
    axiosConfig: {
      url: "/train/dynamic/list-recommend",
      method: "get",
    },
  },
  {
    // 资讯详情
    name: "getAgriNewsDetail",
    axiosConfig: {
      url: "/train/dynamic/newsContent/detail",
      method: "get",
    },
  },
  {
    name: "uploadimg",
    axiosConfig: {
      url: process.env.VUE_APP_API_UPLOAD + "/api/upload/uploadFile",
      method: "post",
      headers: {
        "Content-Type": "multipart/form-data",
      },
    },
  },
  {
    name: "writeReply",
    axiosConfig: {
      url: "/train/course/write-reply",
      method: "post",
    },
  },
  {
    name: "askProblems",
    axiosConfig: {
      url: "/train/course/ask-problem",
      method: "post",
    },
  },
  {
    name: "onlineAsk",
    axiosConfig: {
      url: "/train-hospital/ask-online",
      method: "post",
    },
  },
  {
    name: "getProblemDetail",
    axiosConfig: {
      url: "/train-hospital/hospital-reply-detail",
      method: "get",
    },
  },
  {
    name: "handleProblem",
    axiosConfig: {
      url: "/train-hospital/reply-problem",
      method: "post",
    },
  },
  {
    name: "getCourseType",
    axiosConfig: {
      url: "/train/course/list-courseType",
      method: "get",
    },
  },
  {
    name: "getCourseCategory",
    axiosConfig: {
      url: "/train/course/list-courseCategory",
      method: "get",
    },
  },
  {
    name: "PublishCourse",
    axiosConfig: {
      url: "/train/course/add-course",
      method: "post",
    },
  },
  {
    name: "orderAndRegister",
    axiosConfig: {
      url: "/train-hospital/register",
      method: "post",
    },
  },
  {
    name: "homeService",
    axiosConfig: {
      url: "/train-hospital/home-service",
      method: "post",
    },
  },
  {
    name: "changeCourseStatus",
    axiosConfig: {
      url: "/train/course/change-status",
      method: "get",
    },
  },
  {
    name: "updateCourse",
    axiosConfig: {
      url: "/train/course/update-course",
      method: "post",
    },
  },
  {
    name: "getburyingpoint",
    axiosConfig: {
      url: "/train/course/update-view",
      method: "get",
    },
  },
  {
    name: "getWXcodeAjax",
    axiosConfig: {
      url: "getWXcodeAjax",
      method: "get",
    },
  },
  {
    name: "getCourseOpen",
    axiosConfig: {
      url: "/train/multimedia/course-isclosed",
      method: "get",
    },
  },
  {
    //获取专家申请状态
    name: "getExpert",
    axiosConfig: {
      url: "/third/getExpert",
      method: "post",
    },
  },
  {
    //提交专家入驻申请
    name: "saveExpert",
    axiosConfig: {
      url: "/third/saveExpert",
      method: "post",
    },
  },
  {
    //修改专家入驻申请
    name: "updateExpert",
    axiosConfig: {
      url: "/third/updateExpert",
      method: "post",
    },
  },
  {
    //获取地址
    name: "getArea",
    axiosConfig: {
      url: "/api/config/getArea",
      method: "get",
      requestBase: "gettoken",
    },
  },
  {
    //获取token
    name: "getNewToken",
    axiosConfig: {
      url: "/api/user/sugarTokenLogin",
      method: "post",
      requestBase: "gettoken",
    },
  },
  {
    //获取角色信息
    name: "getRole",
    axiosConfig: {
      url: "/train/course/get-role",
      method: "get",
    },
  },
  {
    //我的课程-删除
    name: "deleteCourse",
    axiosConfig: {
      url: "/train/course/deleteCourse",
      method: "get",
    },
  },
];
export default generateServices(settings);

const nameArray = [];
const urlArray = [];
settings.forEach((item, index) => {
  nameArray.push(item.name);
  urlArray.push(item.axiosConfig.url);
  if (settings[index + 1] && nameArray.includes(settings[index + 1].name)) {
    alert(`name重复,请修改name,重复的name====>${settings[index + 1].name}`);
  }
  if (
    settings[index + 1] &&
    urlArray.includes(settings[index + 1].axiosConfig.url)
  ) {
    alert(
      `url重复,请修改url或复用其他已有接口,重复的url====>${
        settings[index + 1].axiosConfig.url
      }`
    );
  }
});
